/**
 * 
 */
package edu.umd.clip.lm.util;

import java.util.Comparator;

/**
 * @author Denis Filimonov <den@cs.umd.edu>
 *
 */
public class LongAndDoublePair {
	public long theLong;
	public double theDouble;
	
	public LongAndDoublePair(long theLong, double theDouble) {
		this.theLong = theLong;
		this.theDouble = theDouble;
	}
	
	public static final Comparator<LongAndDoublePair> longAscComparator = new Comparator<LongAndDoublePair>() {
		@Override
		public int compare(LongAndDoublePair o1, LongAndDoublePair o2) {
			long sign = o1.theLong - o2.theLong;
			if (sign < 0) return -1;
			if (sign > 0) return 1;
			return 0;
		}
	};
	
	public static final Comparator<LongAndDoublePair> longDescComparator = new Comparator<LongAndDoublePair>() {
		@Override
		public int compare(LongAndDoublePair o1, LongAndDoublePair o2) {
			long sign = o2.theLong - o1.theLong;
			if (sign < 0) return -1;
			if (sign > 0) return 1;
			return 0;
		}
	};
	
	public static final Comparator<LongAndDoublePair> doubleAscComparator = new Comparator<LongAndDoublePair>() {
		@Override
		public int compare(LongAndDoublePair o1, LongAndDoublePair o2) {
			return (int) Math.signum(o1.theDouble - o2.theDouble);
		}
	};
	
	public static final Comparator<LongAndDoublePair> doubleDescComparator = new Comparator<LongAndDoublePair>() {
		@Override
		public int compare(LongAndDoublePair o1, LongAndDoublePair o2) {
			return (int) Math.signum(o2.theDouble - o1.theDouble);
		}
	};

	@Override
	public String toString() {
		return "[" + theLong + ", "	+ theDouble + "]";
	}
}
